package com.voxel.sense.infomsg.utils;

import android.support.annotation.NonNull;

import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.utils.manager.QueryConfigManager;
import com.voxel.sense.infomsg.view.MenuBean;

import java.util.ArrayList;
import java.util.List;

import cyy.example.com.facotry.constants.CommonConstants;
import cyy.example.com.facotry.model.api.response.ConfigEntity;
import cyy.example.com.facotry.model.api.response.SearchMenuEntity;

/**
 * Created by ChenYiYao on 2017/12/9.
 */

public class MenuDataUtil {
    public static List<MenuBean> getPeopleMenuBeanist() {
        ArrayList<MenuBean> list = new ArrayList<>();
        List<ConfigEntity.BodyBean.PersonRolesBean> personRoles = QueryConfigManager.getInstance().getPersonRoles();
        if (personRoles == null || personRoles.size() <= 0) {
            return list;
        }
//        list = new ArrayList<>();
        for (ConfigEntity.BodyBean.PersonRolesBean role : personRoles) {
            if ("1".equals(role.getNote())) {
                MenuBean bean = new MenuBean(role.getRoleName(), role.getRoleId(),
                        CommonConstants.FILE_CONFIG_URL + role.getRoleId() + role.getRoleName() + ".png",
                        true);
                list.add(bean);
            }
        }
        return list;
    }


    //获取任务类型菜单数据
    public static List<MenuBean> getMissionBeanList() {
        ArrayList<MenuBean> list = new ArrayList<>();
//        List<ConfigEntity.BodyBean.TaskTypesBean> taskType =
        SearchMenuEntity taskType = QueryConfigManager.getInstance().getTaskType();
        List<SearchMenuEntity.StaticSystemConstantDetailsBean> type = taskType.getStaticSystemConstantDetails();

        if (type == null || type.size() <= 0) {
            return list;
        }
        for (SearchMenuEntity.StaticSystemConstantDetailsBean taskBean : type) {
            MenuBean bean = null;
            switch(taskBean.getConstantCode()){
                case "1":
                    bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(), true);
                    break;
                case "2":
                    bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(), true);
                    break;
                case "3":
                    bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(),  true);
                    break;
                case "4":
                    bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(),  true);

                    break;
                case "5":
                    bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(),  true);
                    break;
            }
//            MenuBean bean = new MenuBean(taskBean.getConstantName(), taskBean.getConstantCode(), true);
            list.add(bean);
        }
        return list;
    }

    @NonNull
    private static String getMissonUrlIcon(ConfigEntity.BodyBean.TaskTypesBean taskBean) {
        return CommonConstants.FILE_TASK_URL + taskBean.getTaskTypeId() + taskBean.getTaskTypeName() + ".png";
    }
}
